{extend name="public/base"/}
{block name="style"}
<style>
    .category .layui-input{width: 200px !important;}
</style>
{/block}
{block name="content"}
    <div class="data-list" data-url="{:url('index')}">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <input type="text" name="subject" placeholder="主题" class="layui-input">
                </div>
                <div class="layui-inline">
                    <input type="text" name="keyword" placeholder="关键词" class="layui-input">
                </div>
                <div class="layui-inline">
                    <input type="text" name="content" placeholder="邮件内容" class="layui-input">
                </div>
                <div class="layui-inline">
                    <input type="text" placeholder="录入时间" name="create_time" class="layui-input laydate-range">
                </div>
                <div class="layui-inline">
                    <select name="cate_id" lay-filter="data-list" lay-search>
                        <option value="">分类</option>
                        {foreach $category as $c}
                        <option value="{$c.cate_id}">{php}echo str_repeat("├─",$c['level']);{/php}{$c.name}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline">
                    <select name="lang" lay-filter="data-list" lay-search>
                        <option value="">国家</option>
                        {foreach $country as $c}
                        <option value="{$c.code_two}">{$c.name_ch}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layui-btn-normal search"><i class="layui-icon layui-icon-search"></i></button>
                </div>
            </div>
            <div class="pull-right">
                <div class="layui-inline">
                    <a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('add')}"><i class="layui-icon layui-icon-add-circle"></i> 新增</a>
                </div>
            </div>
        </form>
        <div class="data">
            <p><i class="fa fa-spinner fa-spin"></i> 加载中...</p>
        </div>
    </div>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['layer', 'jquery', 'longli'], function()
    {
        var layer = layui.layer
            , $ = layui.jquery;
        $("body").on("click", ".copy-email-template", function()
        {
            var $this = $(this), tempId = $this.attr("item");
            layer.prompt({
                title: '请输入需要关联的订单号,如没有请留空'
                , formType: 0
                , value: ' '
            }, function(text, index)
            {
                layer.close(index);
                $.post("{:url('copy')}", {"sn": text.trim(), "temp_id": tempId}).done(function(response)
                {
                    if(response.code != 1)
                    {
                        layer.msg(response.msg, {icon: 5, time: 1500});
                        return false;
                    }
                    layer.prompt({
                        title: '邮件模板'
                        , btn: ['复制', '取消']
                        , area: ['600px', '400px']
                        , maxlength: 10000000
                        , formType: 2
                        , value: response.data
                    }, function(text, index)
                    {
                        layer.close(index);
                        layui.longli.copyText(text);
                    });
                });
            });
        });
    });
</script>
{/block}